<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


include_once 'conexao.php';
$conexao=  BancoDeDados::getInstance();
$query="SELECT idPRODUTOR as value,nome as label from produtor";
$names = array();



$result=mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
$cont=0;
while($row = mysql_fetch_array($result,MYSQLI_ASSOC)) 
 { 
    //$names[$cont] = $row['nome']; funcionando
    $names[$cont] = $row;
 
 
 //echo "$names[$cont]";
 $cont++;
             }
 header('Content-type: application/json');            
echo json_encode($names);



// $arr = array(
//
//            "name" => "Tim",
//            "age" => "28"     );
//
//echo json_encode($arr);